const type = {
  SET_USERNAME: 'SET_USERNAME'
}

const state = {
  username: ''
}

const getters = {
  username: (state) => state.username
}

const mutations = {
  [type.SET_USERNAME](state, username) {
    if (username) state.username = username
    else state.username = ''
  }
}

const actions = {
  setUsername: ({commit}, username) => {
    commit(type.SET_USERNAME, username)
  }
}

export default {
  state,
  getters,
  mutations,
  actions
}
